package com.kingint.web.portal.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kingint.mbg.bas.entity.BasFloor;
import com.kingint.mbg.bas.mapper.BasFloorMapper;
import com.kingint.web.admin.base.service.BasFloorService;
import com.kingint.web.portal.base.service.FloorService;
import com.kingint.web.sys.service.UmsMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * <p>
 * 楼层表 服务实现类
 * </p>
 *
 * @author wxh
 * @since 2020-12-21
 */
@Service
public class FloorServiceImpl extends ServiceImpl<BasFloorMapper, BasFloor> implements FloorService {

    @Resource
    private BasFloorMapper basFloorMapper;
    @Autowired
    private UmsMemberService umsMemberService;

    @Override
    public IPage<BasFloor> pagelist(Page<BasFloor> page, BasFloor basFloor) {
        QueryWrapper<BasFloor> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("hotel_id",umsMemberService.getUserHotel());
        if (!StringUtils.isEmpty(basFloor.getFloorName())){
            queryWrapper.eq("floor_name",basFloor.getFloorName());
        }
        IPage<BasFloor> basFloorIPage = basFloorMapper.selectPage(page, queryWrapper);
        return basFloorIPage;
    }
}
